From bf0ea7b7bc8de1c39923d4976f6e1aafd23b92c7 Mon Sep 17 00:00:00 2001 From: Daniel Boles Date: Mon, 6 Mar 2017 20:29:04 +0000 Subject: [PATCH] Fix the completely broken tests/testheightforwidth MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This was ruined, with only 1 of the 8 subwindows rendering any content. This commit fixes the responsible errors in the embedded GtkBuilder UIs: • Fix broken replace by commit fb3d9022ad98049c887cec5aeffd6b73deb043ba of HBox with a Box having a broken orientation • Replace VBox and [HV]Paned with GtkOrientable successors (properly!) • Remove use of Button:use_action_appearance, as this no longer exists This commit also adds error reporting, in case other errors creep into the GtkBuilder UI definitions, plus cleanup for the Builders and Windows --- tests/testheightforwidth.c | 94 +++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/tests/testheightforwidth.c b/tests/testheightforwidth.c index b1108388e4..295a5ca26f 100644 --- a/tests/testheightforwidth.c +++ b/tests/testheightforwidth.c @@ -32,19 +32,19 @@ typedef struct { * * IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade */ -TestInterface interfaces[] = { +static TestInterface interfaces[] = { { "Ellipsizing Labels", "Demonstrates how labels will request a natural size in a horizontal space", "" - " " + " " " " " " " 450" " 50" " " " " - " " + " horizontal" " True" " " " " @@ -99,16 +99,18 @@ TestInterface interfaces[] = { "Wrapping Label", "Demonstrates how a wrapping label can require a height contextual to its allocated width", "" - " " + " " " " " " " 300" " " - " " + " " + " horizontal" " True" " True" " " - " " + " " + " vertical" " True" " " " " @@ -198,28 +200,29 @@ TestInterface interfaces[] = { "Horizontal Box", "Demonstrates how a horizontal box can calculate the collective height for an allocated width", "" - " " + " " " " " " " 200" " 600" " " - " " + " " + " horizontal" " True" " True" " " - " " + " " + " vertical" " True" " " " " - " " + " horizontal" " True" " " " " " True" " True" " True" - " False" " " " " " True" @@ -263,7 +266,6 @@ TestInterface interfaces[] = { " True" " True" " True" - " False" " " " " " 1" @@ -304,18 +306,19 @@ TestInterface interfaces[] = { "Demonstrates how a horizontal box will consider width-for-height when allocating children " "even if the toplevel window is requested as height-for-width.", "" - " " + " " " " " " " 400" " 300" " " - " " + " " + " vertical" " True" " True" " " " " - " " + " horizontal" " True" " " " " @@ -367,7 +370,7 @@ TestInterface interfaces[] = { " " " " " " - " " + " horizontal" " True" " " " " @@ -429,20 +432,22 @@ TestInterface interfaces[] = { "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used " "to effect minimum and natural widths in wrapping labels.", "" - " " + " " " " " " " 900" " " - " " + " " + " horizontal" " True" " True" " " - " " + " " + " vertical" " True" " " " " - " " + " horizontal" " True" " 6" " " @@ -554,12 +559,13 @@ TestInterface interfaces[] = { "and also trade height for width.", "" "" - " " + " " " " " " " 500" " " - " " + " " + " horizontal" " True" " True" " " @@ -624,7 +630,7 @@ TestInterface interfaces[] = { "and also trade height for width.", "" "" - " " + " " " " " " " 400" @@ -636,7 +642,7 @@ TestInterface interfaces[] = { " " " " " True" - " 12" + " 12" " some content" " " " " @@ -660,21 +666,23 @@ TestInterface interfaces[] = { "This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).", "" "" - " " + " " " " " " " 600" " " - " " + " " + " horizontal" " True" " True" " " - " " + " " + " vertical" " True" " 5" " " " " - " " + " horizontal" " True" " 5" " " @@ -776,7 +784,7 @@ TestInterface interfaces[] = { " " " " " " - " " + " horizontal" " True" " 5" " " @@ -920,12 +928,24 @@ test_clicked (GtkWidget *button, if (!interface->window) { GtkBuilder *builder = gtk_builder_new (); + GError *error = NULL; - gtk_builder_add_from_string (builder, interface->interface, -1, NULL); + gtk_builder_add_from_string (builder, interface->interface, -1, &error); + + if (error) + { + g_printerr ("GtkBuilder for interface \"%s\" returned error \"%s\"\n", + interface->name, error->message); + g_error_free (error); + return; + } + interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window"); g_signal_connect (interface->window, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); + + g_object_unref (builder); } gtk_widget_show (interface->window); @@ -960,7 +980,19 @@ create_window (void) return window; } +static void +main_window_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + for (gsize i = 0; i < sizeof(interfaces) / sizeof(TestInterface); ++i) + { + if (interfaces[i].window) + { + gtk_widget_destroy (interfaces[i].window); + } + } + gtk_main_quit (); +} int main (int argc, char *argv[]) @@ -972,7 +1004,7 @@ main (int argc, char *argv[]) window = create_window (); g_signal_connect (window, "delete-event", - G_CALLBACK (gtk_main_quit), window); + G_CALLBACK (main_window_delete_cb), window); gtk_widget_show (window); -- 2.30.2